package com.project.service.impl;

import com.project.bean.FacilitiesBean;
import com.project.mapper.IFacilitiesMapper;
import com.project.service.IFacilitiesService;
import org.apache.ibatis.session.SqlSession;

import java.util.List;

public class FaciltiesService extends BaseService implements IFacilitiesService {
    @Override
    public List<FacilitiesBean> findByRoom(int roomId) {
        SqlSession session=this.getSession();
        IFacilitiesMapper mapper=session.getMapper(IFacilitiesMapper.class);
        List<FacilitiesBean>list=mapper.findByRoom(roomId);
        session.close();
        return list;
    }

    @Override
    public void add(FacilitiesBean facilitiesBean, int roomId) {
        SqlSession session=this.getSession();
        IFacilitiesMapper mapper=session.getMapper(IFacilitiesMapper.class);
        mapper.add(facilitiesBean,roomId);
        session.commit();
        session.close();


    }

    @Override
    public void updateFacilities(int facilitiesId, int roomId) {
        SqlSession session=this.getSession();
        IFacilitiesMapper mapper=session.getMapper(IFacilitiesMapper.class);
        mapper.updateFacilities(facilitiesId,roomId);
        session.commit();
        session.close();

    }
}
